from django import template

register = template.Library()


@register.filter(name='sub')
def subtract(value, arg):
    try:
        return value - arg
    except (ValueError, TypeError):
        return ''  # 或者你可以返回一个错误消息或默认值

